package com.schoolET.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.schoolET.entity.Administrators;
import com.schoolET.entity.dto.AdminListDTO;
import com.schoolET.entity.vo.AdminSelectVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface RegionalAdminMapper extends BaseMapper<RegionalAdminMapper> {
    //无条件查询管理员
    @Select("select * from administrators where flag = 0")
    List<Administrators> selectAllAdmin();

    //通过名字和地区名分页查询管理员
    Page<AdminListDTO> selectAllAdminByNameAndPosition(Page<?> page, @Param("adminSelectVO")AdminSelectVO adminSelectVO);

    @Select("SELECT * FROM administrators " +
            "WHERE (account= #{account} \n" +
            "OR name = #{name}) \n" +
            "and id != #{id}")
    List<Administrators> selectAdminByAll(Administrators administrators);

    @Select("SELECT * FROM administrators " +
            "WHERE account= #{account} \n" +
            "OR name = #{name}")
    List<Administrators> selectAdminByAccountAndName(Administrators administrators);
}
